<template>
	<view class="bigBox">
		<u-navbar :fixed="true" :placeholder="true" title="新增辨识" @leftClick="leftClick" bgColor="#0F53AC"
			leftIconColor="#fff">
		</u-navbar>
		<view class="kiss-upDown-list">
			<view class="bx-list-title">
				<view class="left">
					风险点名称
				</view>
			</view>
			<view class="textInput">{{pointName}}</view>
		</view>
		<view class="kiss-upDown-list">
			<view class="bx-list-title">
				<view class="left">
					风险点位置
				</view>
			</view>
			<view class="textInput">{{location}}</view>
		</view>
		<view class="kiss-upDown-list">
			<view class="bx-list-title">
				<view class="left">
					<view style="color: red;" v-if="isInspec == 0">*</view>
					危险因素描述
				</view>
			</view>
			<view class="input-textrea" v-if="isInspec == 0">
				<u--textarea class="textrea" v-model="dataForm.riskFactor" cursorSpacing="60" count
					placeholder="请输入危险因素描述" maxlength="120">
				</u--textarea>
			</view>
			<view class="textInput" v-else>{{dataForm.riskFactor || '无'}}</view>
		</view>
		<view class="kiss-list" @click="handleRectifyDept">
			<view class="kiss-list-title">
				<view class="left">
					<view style="color: red;" v-if="isInspec == 0">*</view>
					事故类型
				</view>
				<view class="right1" v-if="isInspec == 0">
					<view style="overflow: hidden;text-overflow: ellipsis;white-space: nowrap;"
						:class="[selectAccident.length ? 'select-bg' : 'sel']">
						{{ selectAccident.length ? format(selectAccident) : '请选择' }}
					</view>
					<u-icon name="arrow-right"></u-icon>
				</view>
				<view class="right1" v-else>
					<view :class="[dataForm.rectifyDeptName != '' ? 'select-bg' : '']">
						{{ dataForm.rectifyDeptName != '' ? dataForm.rectifyDeptName : '无' }}
					</view>
				</view>
			</view>
		</view>
		<view class="kiss-list" @click="showMethod=true">
			<view class="kiss-list-title">
				<view class="left">
					<view style="color: red;" v-if="isInspec == 0">*</view>
					风险评价方法
				</view>
				<view class="right1" v-if="isInspec == 0">
					<view style="overflow: hidden;text-overflow: ellipsis;white-space: nowrap;"
						:class="[dataForm.evaluateName != '' ? 'select-bg' : 'sel']">
						{{ dataForm.evaluateName != '' ? dataForm.evaluateName : '请选择' }}
					</view>
					<u-icon name="arrow-right"></u-icon>
				</view>
				<view class="right1" v-else>
					<view :class="[dataForm.evaluateName != '' ? 'select-bg' : '']">
						{{ dataForm.evaluateName != '' ? dataForm.evaluateName : '无' }}
					</view>
				</view>
			</view>
		</view>
		<!-- LEC -->
		<template v-if="dataForm.evaluateWay == 2">
			<view class="kiss-list" @click="showPossibility2=true">
				<view class="kiss-list-title">
					<view class="left">
						<view style="color: red;" v-if="isInspec == 0">*</view>
						发生可能性(L)
					</view>
					<view class="right1" v-if="isInspec == 0">
						<view style="overflow: hidden;text-overflow: ellipsis;white-space: nowrap;"
							:class="[dataForm.possibility != '' ? 'select-bg' : 'sel']">
							{{ dataForm.possibility != '' ? dataForm.possibility : '请选择' }}
						</view>
						<u-icon name="arrow-right"></u-icon>
					</view>
				</view>
			</view>
			<view class="kiss-list" @click="showFrequentDegree=true">
				<view class="kiss-list-title">
					<view class="left">
						<view style="color: red;" v-if="isInspec == 0">*</view>
						暴露频繁程度(E)
					</view>
					<view class="right1" style="width: 55vw;" v-if="isInspec == 0">
						<view style="overflow: hidden;text-overflow: ellipsis;white-space: nowrap;"
							:class="[dataForm.frequentDegree != '' ? 'select-bg' : 'sel']">
							{{ dataForm.frequentDegree != '' ? dataForm.frequentDegree : '请选择' }}
						</view>
						<u-icon name="arrow-right"></u-icon>
					</view>
				</view>
			</view>
			<view class="kiss-list" @click="showLossResultant=true">
				<view class="kiss-list-title">
					<view class="left">
						<view style="color: red;" v-if="isInspec == 0">*</view>
						损失后果(C)
					</view>
					<view class="right1" v-if="isInspec == 0">
						<view style="overflow: hidden;text-overflow: ellipsis;white-space: nowrap;"
							:class="[dataForm.lossResultant != '' ? 'select-bg' : 'sel']">
							{{ dataForm.lossResultant != '' ? dataForm.lossResultant : '请选择' }}
						</view>
						<u-icon name="arrow-right"></u-icon>
					</view>
				</view>
			</view>
		</template>
		<!-- LS -->
		<template v-if="dataForm.evaluateWay == 3">
			<view class="kiss-list" @click="showPossibility=true">
				<view class="kiss-list-title">
					<view class="left">
						<view style="color: red;" v-if="isInspec == 0">*</view>
						发生可能性(L)
					</view>
					<view class="right1" v-if="isInspec == 0">
						<view style="overflow: hidden;text-overflow: ellipsis;white-space: nowrap;"
							:class="[dataForm.possibility != '' ? 'select-bg' : 'sel']">
							{{ dataForm.possibility != '' ? dataForm.possibility : '请选择' }}
						</view>
						<u-icon name="arrow-right"></u-icon>
					</view>
				</view>
			</view>
			<view class="kiss-list" @click="showSeriousDegree=true">
				<view class="kiss-list-title">
					<view class="left">
						<view style="color: red;" v-if="isInspec == 0">*</view>
						严重程度(S)
					</view>
					<view class="right1" v-if="isInspec == 0">
						<view style="overflow: hidden;text-overflow: ellipsis;white-space: nowrap;"
							:class="[dataForm.seriousDegree != '' ? 'select-bg' : 'sel']">
							{{ dataForm.seriousDegree != '' ? dataForm.seriousDegree : '请选择' }}
						</view>
						<u-icon name="arrow-right"></u-icon>
					</view>
				</view>
			</view>
		</template>
		<view class="kiss-list" @click="handleRiskLevel">
			<view class="kiss-list-title">
				<view class="left">
					<view style="color: red;" v-if="isInspec == 0">*</view>
					风险等级
				</view>
				<view class="right1" v-if="isInspec == 0">
					<view :class="[dataForm.riskLevelName != '' ? 'select-bg' : 'sel']">
						{{ dataForm.riskLevelName != '' ? dataForm.riskLevelName : '请选择' }}
					</view>
					<u-icon name="arrow-right"></u-icon>
				</view>
			</view>
		</view>
		<u-gap height="6" bgColor="#f2f2f2"></u-gap>
		<view class="kiss-title">
			<view class="left">
				<view style="color: red;" v-if="isInspec == 0">*</view>安全标志<view v-if="isInspec == 0"
					style="color: #8c8c8c;">(最多9个)</view>
			</view>
		</view>
		<view class="kiss-upload" style="padding: 0 32rpx;">
			<view class="imgBox">
				<view class="img" v-for="(v,index) in imgList" :key="index">
					<image @tap="previewImage(v,imgList)" :src="v"></image>
					<view class="delect-icon" @tap="delectImg(index)">
						<image class="full" :src="clearIcon" mode=""></image>
					</view>
				</view>
				<view class="img-add" @click="handleAddImg" v-if="imgList.length <9">
					<image class="image" src="../../../static/images/index/camera2.png"></image>
				</view>

			</view>

		</view>
		<view v-for="(item,index) in selectAccident" :key="item.accidentTypeId">
			<view class="kiss-upDown-list">
				<view class="bx-list-title">
					<view class="left">
						<view style="color: red;" v-if="isInspec == 0">*</view>
						{{`${item.accidentTypeName}应急处置措施`}}
					</view>
				</view>
				<view class="input-textrea">
					<u--textarea class="textrea" v-model="item.measures" cursorSpacing="60" placeholder="请输入隐患描述"
						maxlength="1000">
					</u--textarea>
				</view>
			</view>
		</view>



		<!-- 底部按钮 -->
		<view class="bottom-subside" style="height: 136rpx;"></view>
		<view class="bx-bottom">
			<view class="btn-left" @click="$dianji(handleZancun,'onoff1')">保存草稿并返回</view>
			<view class="btn-right" @click="$dianji(sumbit,'onoff')">提交</view>
		</view>

		<!-- 风险评价方法 -->
		<u-picker :show="showMethod" :columns="methodColumns" keyName="name" @confirm="onChangeMethod"
			@cancel="cancelMethod">
		</u-picker>
		<!-- 风险等级 -->
		<u-picker :show="showRiskLevel" :columns="riskLevelColumns" keyName="name" @confirm="onChangeRiskLevel"
			@cancel="cancelRiskLevel">
		</u-picker>
		<!-- LEC -->
		<!-- 发生可能性2 -->
		<u-picker title='请选择事故发生可能性大小' :show="showPossibility2" :columns="possibilityColumns2" keyName="configValue"
			@confirm="onChangePossibility2" @cancel="cancelPossibility2">
		</u-picker>
		<!-- 暴露频繁程度 -->
		<u-picker title='请选择人体暴露在这种危险环境暴露频繁程度' :show="showFrequentDegree" :columns="frequentDegreeColumns"
			keyName="configValue" @confirm="onChangeFrequentDegree" @cancel="cancelFrequentDegree">
		</u-picker>
		<!-- 损失后果 -->
		<u-picker title='请选择一旦发生事故会造成的损失' :show="showLossResultant" :columns="lossResultantColumns"
			keyName="configValue" @confirm="onChangeLossResultant" @cancel="cancelLossResultant">
		</u-picker>

		<!-- LS -->
		<!-- 发生可能性 -->
		<u-picker title='请选择事故发生可能性大小' :show="showPossibility" :columns="possibilityColumns" keyName="configValue"
			@confirm="onChangePossibility" @cancel="cancelPossibility">
		</u-picker>
		<!-- 严重程度 -->
		<!-- <u-picker :show="showSeriousDegree" :columns="seriousDegreeColumns" keyName="configValue"
			@confirm="onChangeSeriousDegree" @cancel="cancelSeriousDegree">
		</u-picker> -->

		<!-- 事故类型 -->
		<u-popup :show="showAccidentType" mode="bottom" :round="10">
			<view class="kiss-popup">
				<view class="picker-btn">
					<view class="left" @click="cancelAccidentType">取消</view>
					<view style="font-size: 34rpx;font-weight: 500;">事故类型(可多选)</view>
					<view class="right" @click="confirmAccidentType">确定</view>
				</view>
				<view class="main">
					<view v-for="(item,index) in allAccidentType" :key="index" @click="handleMainItem(item)"
						:class="[item.checked?'main-item-active':'']" class="main-item">
						{{item.accidentTypeName}}
						<view class="item-check" v-if="item.checked">
							<image src="../../../static/images/index/checked.png"></image>
						</view>

					</view>
				</view>
			</view>
		</u-popup>
		<!-- 严重程度 -->
		<u-popup :show="showSeriousDegree" mode="bottom" :round="10" @close="cancelSeriousDegree" @open="open">
			<view
				style="padding: 16rpx 0;color: #2B2B2B;font-size: 34rpx; font-weight:500;text-align: center;border-bottom: 1px solid #f5f5f5;height: 80rpx;line-height: 80rpx;">
				请选择危害事件发生的严重程度</view>
			<view class="sex-select">
				<view class="sex-item" :class="[item.checked?'sex-item-active':'']" @click="onChangeSeriousDegree(item)"
					v-for="(item,index) in seriousDegreeColumns" :key="index">
					{{item.configValue}}
					<view class="item-check" v-if="item.checked">
						<image src="../../../static/images/index/checked.png"></image>
					</view>
				</view>
			</view>
		</u-popup>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				clearIcon: '',
				pointId: '', //风险点id
				pointName: '', //风险点名称
				location: '', //风险点位置
				isInspec: 0, // 0 编辑 1 查看详情
				showAccidentType: false, //事故类型
				allAccidentType: [],
				selectAccident: [], //选中的事故类型

				showMethod: false,
				methodColumns: [
					[{
							id: 1,
							name: '直接判定法'
						},
						{
							id: 2,
							name: '作业条件危险性评价分析法（LEC）'
						},
						{
							id: 3,
							name: '风险矩阵法（LS）'
						},
					]
				],
				showRiskLevel: false,
				riskLevelColumns: [
					[{
							id: 1,
							name: '重大风险'
						},
						{
							id: 2,
							name: '较大风险'
						},
						{
							id: 3,
							name: '一般风险'
						},
						{
							id: 4,
							name: '低风险'
						},
					]
				],
				showPossibility: false,
				possibilityColumns: [

				],
				showSeriousDegree: false,
				seriousDegreeColumns: [

				],

				showPossibility2: false,
				possibilityColumns2: [],

				showFrequentDegree: false,
				frequentDegreeColumns: [

				],

				showLossResultant: false,
				lossResultantColumns: [

				],

				dataForm: {
					riskFactor: '', //危险因素描述
					evaluateName: '', //风险评价方法名称
					evaluateWay: '', //风险评价方法 1.直接判定法；2.作业条件危险性评价分析法（lec）；3.风险矩阵法（ls）；
					riskLevelName: '', //风险等级名称
					riskLevel: '', //风险等级；1.重大风险；2.较大风险；3.一般风险；4.低风险；
					possibility: '', //发生可能性
					seriousDegree: '', //严重程度
					frequentDegree: '', // 暴露的频繁程度
					lossResultant: '', //损失后果
					symbolIds: '',
					symbolPictures: ''

				},
				onoff: true,
				onoff1: true,
				fileList1: [],
				imgList: [],
				file: ''
			};
		},
		onLoad(options) {
			this.getAllAccidentType()
			this.getDictype()
			if (options) {
				// 风险点id
				this.pointId = options.pointId
				// 风险点名称
				this.pointName = options.pointName
				// 风险点位置
				this.location = options.location
				this.draftIdentifyId = options.draftIdentifyId
			}
			if (this.draftIdentifyId) this.initData()


			// 选择安全标志
			uni.$on('addSave', (data) => {
				let idArr = []
				let nameArr = []
				data.forEach(item => {
					idArr.push(item.id)
					nameArr.push(item.symbolPicture)
				})

				this.dataForm.symbolIds = idArr.join(',')
				this.dataForm.symbolPictures = nameArr.join(',')
				this.imgList = nameArr
			})
		},
		methods: {
			leftClick() {
				var that = this;
				uni.showModal({
					title: '提示',
					content: '是否保存当前记录？',
					confirmText: '保存',
					cancelText: '不保存',
					success: function(res) {
						if (res.confirm) {
							that.handleZancun();
						} else if (res.cancel) {
							uni.navigateBack({
								delta: 1
							});
						}
					}
				});
			},
			initData() {
				uni.$u.http.get(`/check/mobile/riskIdentifyRecord/getInfo/${this.draftIdentifyId}`).then(res => {
					if (res.code == 0) {
						this.dataForm = res.data

						// 严重程度回显
						if (res.data.seriousDegree) {
							this.seriousDegreeColumns.map(it => {
								if (it.configValue == res.data.seriousDegree) {
									it.checked = true
								}
							})
						}
						this.selectAccident = res.data.identifyAccidentList
						// 安全标志回显
						if (res.data.symbolPictures) this.imgList = res.data.symbolPictures.split(',')

						// 回显
						if (res.data.evaluateWay) {
							this.dataForm.evaluateName = this.methodColumns[0].filter(item => item.id == res.data
								.evaluateWay)[0].name
						} else {
							this.dataForm.evaluateName = ''
						}
						if (res.data.riskLevel) {
							this.dataForm.riskLevelName = this.riskLevelColumns[0].filter(item => item.id == res
								.data.riskLevel)[0].name
						} else {
							this.dataForm.riskLevelName = ''
						}
					}
				}).catch(err => {})
			},
			// 获取字典
			getDictype() {
				// lec_l
				uni.$u.http.post(`/check/mobile/dataDictionary/dictionaryList`, {
					configType: 'lec_l'
				}).then(res => {
					if (res.code == 0) {
						this.possibilityColumns2 = [res.data]
					}
				}).catch(err => {})
				// lec_e
				uni.$u.http.post(`/check/mobile/dataDictionary/dictionaryList`, {
					configType: 'lec_e'
				}).then(res => {
					if (res.code == 0) {
						this.frequentDegreeColumns = [res.data]
					}
				}).catch(err => {})
				// lec_c
				uni.$u.http.post(`/check/mobile/dataDictionary/dictionaryList`, {
					configType: 'lec_c'
				}).then(res => {
					if (res.code == 0) {
						this.lossResultantColumns = [res.data]
					}
				}).catch(err => {})
				// ls_l
				uni.$u.http.post(`/check/mobile/dataDictionary/dictionaryList`, {
					configType: 'ls_l'
				}).then(res => {
					if (res.code == 0) {
						this.possibilityColumns = [res.data]
					}
				}).catch(err => {})
				// ls_s
				uni.$u.http.post(`/check/mobile/dataDictionary/dictionaryList`, {
					configType: 'ls_s'
				}).then(res => {
					if (res.code == 0) {
						this.seriousDegreeColumns = res.data
					}
				}).catch(err => {})
			},
			getAllAccidentType() {
				uni.$u.http.get(`/check/mobile/riskAccidentType/getAllAccidentType`).then(res => {
					if (res.code == 0) {
						res.data.map(item => {
							item.checked = false
						})
						this.allAccidentType = res.data
					}
				}).catch(err => {})
			},
			handleMainItem(item) {
				item.checked = !item.checked
			},
			handleZancun() {

				let arr = []
				this.selectAccident.map(item => {
					let obj = {
						accidentTypeId: item.accidentTypeId,
						accidentTypeName: item.accidentTypeName,
						measures: item.measures
					}
					arr.push(obj)
				})
				let params = {
					pointId: this.pointId,
					riskFactor: this.dataForm.riskFactor,
					evaluateWay: this.dataForm.evaluateWay,
					symbolIds: this.dataForm.symbolIds, //安全标志
					symbolPictures: this.dataForm.symbolPictures, //安全标志
					identifyAccidentList: arr
				}
				if (this.dataForm.evaluateWay == 1) {
					params.riskLevel = this.dataForm.riskLevel
				} else if (this.dataForm.evaluateWay == 2) {
					params.possibility = this.dataForm.possibility
					params.frequentDegree = this.dataForm.frequentDegree
					params.lossResultant = this.dataForm.lossResultant
					params.riskLevel = this.dataForm.riskLevel
				} else if (this.dataForm.evaluateWay == 3) {
					params.possibility = this.dataForm.possibility
					params.seriousDegree = this.dataForm.seriousDegree
					params.riskLevel = this.dataForm.riskLevel
				}
				if (this.dataForm.id) {
					params.id = this.dataForm.id
				}
				uni.$u.http.post(`/check/mobile/riskIdentifyRecord/addIdentifyRecord`, params).then(res => {
					if (res.code == 0) {
						uni.$u.toast('提交成功')
						uni.navigateBack({ //uni.navigateTo跳转的返回，默认1为返回上一级
							delta: 1
						});
					}
				}).catch(err => {})
			},
			sumbit() {
				if (!this.dataForm.riskFactor) {
					uni.$u.toast('请填写危险因素描述')
					return
				}
				if (!this.selectAccident.length) {
					uni.$u.toast('请选择事故类型')
					return
				}
				if (!this.dataForm.evaluateWay) {
					uni.$u.toast('请选择风险评价方法')
					return
				}

				let arr = []
				this.selectAccident.map(item => {
					let obj = {
						accidentTypeId: item.accidentTypeId,
						accidentTypeName: item.accidentTypeName,
						measures: item.measures
					}
					arr.push(obj)
				})
				if (arr.filter(item => !item.measures).length) {
					uni.$u.toast('请填写完整对应应急措施')
					return
				}
				if (!this.dataForm.symbolPictures.length) {
					uni.$u.toast('请至少选择一个安全标志')
					return
				}

				let params = {
					pointId: this.pointId,
					riskFactor: this.dataForm.riskFactor,
					evaluateWay: this.dataForm.evaluateWay,
					symbolIds: this.dataForm.symbolIds, //安全标志
					symbolPictures: this.dataForm.symbolPictures, //安全标志
					identifyAccidentList: arr
				}
				if (this.dataForm.evaluateWay == 1) {
					if (!this.dataForm.riskLevel) {
						uni.$u.toast('请选择风险等级')
						return
					}
					params.riskLevel = this.dataForm.riskLevel
				} else if (this.dataForm.evaluateWay == 2) {
					if (!this.dataForm.possibility) {
						uni.$u.toast('请选择事故发生可能性大小')
						return
					}
					params.possibility = this.dataForm.possibility
					if (!this.dataForm.frequentDegree) {
						uni.$u.toast('请选择暴露的频繁程度')
						return
					}
					params.frequentDegree = this.dataForm.frequentDegree
					if (!this.dataForm.lossResultant) {
						uni.$u.toast('请选择损失后果')
						return
					}
					params.lossResultant = this.dataForm.lossResultant
					params.riskLevel = this.dataForm.riskLevel
				} else if (this.dataForm.evaluateWay == 3) {
					if (!this.dataForm.possibility) {
						uni.$u.toast('请选择事故发生可能性大小')
						return
					}
					params.possibility = this.dataForm.possibility
					if (!this.dataForm.seriousDegree) {
						uni.$u.toast('请选择严重程度')
						return
					}
					params.seriousDegree = this.dataForm.seriousDegree
					params.riskLevel = this.dataForm.riskLevel
				}
				if (this.dataForm.id) {
					params.id = this.dataForm.id
				}

				uni.$u.http.post(`/check/mobile/riskIdentifyRecord/submitIdentifyRecord`, params).then(res => {
					if (res.code == 0) {
						uni.$u.toast('提交成功')

						uni.navigateBack({ //uni.navigateTo跳转的返回，默认1为返回上一级
							delta: 1
						});
					}
				}).catch(err => {})
			},
			confirmAccidentType() {
				let arr = this.allAccidentType.filter(item => item.checked)
				this.selectAccident = arr
				this.dataForm.identifyAccidentList = arr
				this.showAccidentType = false
			},
			cancelAccidentType() {
				this.allAccidentType.map(item => item.checked = false)
				this.showAccidentType = false
			},
			handleRectifyDept() {
				this.allAccidentType.map(item => {
					this.selectAccident.map(it => {
						if (item.accidentTypeId == it.accidentTypeId) item.checked = true
					})
				})
				this.showAccidentType = true
			},
			onChangeMethod(e) {
				if (e.value[0]) {
					this.dataForm.evaluateName = e.value[0].name
					this.dataForm.evaluateWay = e.value[0].id
				}
				// 每次选择清空风险等级
				this.dataForm.riskLevel = ''
				this.dataForm.riskLevelName = ''
				this.dataForm.possibilityName = '' //发生可能性名称
				this.dataForm.possibility = '' //发生可能性
				this.dataForm.seriousDegreeName = '' //严重程度名称
				this.dataForm.seriousDegree = '' //严重程度
				this.dataForm.frequentDegreeName = '' // 暴露的频繁程度名称
				this.dataForm.frequentDegree = '' // 暴露的频繁程度
				this.dataForm.lossResultantName = '' //损失后果名称
				this.dataForm.lossResultant = '' //损失后果
				this.showMethod = false
			},
			cancelMethod() {
				this.showMethod = false
			},
			handleRiskLevel() {
				if (!this.dataForm.evaluateWay) {
					uni.$u.toast('请先选择评价方法')
					return
				}
				if (this.dataForm.evaluateWay != 1) {
					return
				}
				this.showRiskLevel = true
			},
			onChangeRiskLevel(e) {
				if (e.value[0]) {
					this.dataForm.riskLevelName = e.value[0].name
					this.dataForm.riskLevel = e.value[0].id
				}
				this.showRiskLevel = false
			},
			cancelRiskLevel() {
				this.showRiskLevel = false
			},

			onChangePossibility(e) {
				if (e.value[0]) {
					this.dataForm.possibility = e.value[0].configValue
				}
				// 如果严重程度有值 重新计算
				if (this.dataForm.seriousDegree) {
					let params = {
						evaluateWay: 3, // 评价方法3.风险矩阵法（LS）；
						possibility: e.value[0].configValue,
						seriousDegree: this.dataForm.seriousDegree
					}
					uni.$u.http.post(`/check/mobile/riskIdentifyRecord/calculateRiskLevel`, params).then(res => {
						if (res.code == 0) {
							this.dataForm.riskLevel = res.data
							this.dataForm.riskLevelName = this.riskLevelColumns[0].filter(item => item.id == res
								.data)[0].name
						}
					}).catch(err => {})
				}
				this.showPossibility = false
			},
			cancelPossibility() {
				this.showPossibility = false
			},
			open() {},
			onChangeSeriousDegree(item) {
				if (item) {
					this.seriousDegreeColumns.map(it => it.checked = false)
					item.checked = true
					this.dataForm.seriousDegree = item.configValue
				}
				// 如果严重程度有值 重新计算
				if (this.dataForm.possibility) {
					let params = {
						evaluateWay: 3, // 评价方法3.风险矩阵法（LS）；
						possibility: this.dataForm.possibility,
						seriousDegree: item.configValue
					}
					uni.$u.http.post(`/check/mobile/riskIdentifyRecord/calculateRiskLevel`, params).then(res => {
						if (res.code == 0) {
							this.dataForm.riskLevel = res.data
							this.dataForm.riskLevelName = this.riskLevelColumns[0].filter(item => item.id == res
								.data)[0].name
						}
					}).catch(err => {})
				}
				this.showSeriousDegree = false
			},
			cancelSeriousDegree() {
				this.showSeriousDegree = false
			},

			getRiskLevel() {
				let params = {
					evaluateWay: 2, // 评价方法2作业条件危险性评价分析法（LEC）；
					possibility: this.dataForm.possibility,
					frequentDegree: this.dataForm.frequentDegree,
					lossResultant: this.dataForm.lossResultant
				}
				uni.$u.http.post(`/check/mobile/riskIdentifyRecord/calculateRiskLevel`, params).then(res => {
					if (res.code == 0) {
						this.dataForm.riskLevel = res.data
						this.dataForm.riskLevelName = this.riskLevelColumns[0].filter(item => item.id == res
							.data)[0].name
					}
				}).catch(err => {})
			},

			onChangePossibility2(e) {
				if (e.value[0]) {
					this.dataForm.possibility = e.value[0].configValue
				}
				// 如果暴露频繁程度和损失后果有值 重新计算
				if (this.dataForm.frequentDegree && this.dataForm.lossResultant) {
					this.getRiskLevel()
				}
				this.showPossibility2 = false
			},
			cancelPossibility2() {
				this.showPossibility2 = false
			},

			onChangeFrequentDegree(e) {
				if (e.value[0]) {
					this.dataForm.frequentDegree = e.value[0].configValue
				}
				// 如果  重新计算
				if (this.dataForm.possibility && this.dataForm.lossResultant) {
					this.getRiskLevel()
				}
				this.showFrequentDegree = false
			},
			cancelFrequentDegree() {
				this.showFrequentDegree = false
			},

			onChangeLossResultant(e) {
				if (e.value[0]) {
					this.dataForm.lossResultant = e.value[0].configValue
				}
				// 如果  重新计算
				if (this.dataForm.possibility && this.dataForm.frequentDegree) {
					this.getRiskLevel()
				}
				this.showLossResultant = false
			},
			cancelLossResultant() {
				this.showLossResultant = false
			},

			format(arr) {
				let newArr = []
				arr.map(item => {
					newArr.push(item.accidentTypeName)
				})
				return newArr.join(',')
			},
			handleAddImg() {
				uni.navigateTo({
					url: `/pages/subPackagesA/riskIdtion/saveMark?symbolIds=${this.dataForm.symbolIds}&symbolPictures=${this.dataForm.symbolPictures}`
				})
			},
			//预览图片
			previewImage: function(e, s) {
				let imgList = []
				if (s.pictures) {
					imgList = this.getpictureList(s.pictures)
				} else {
					imgList = s
				}
				uni.previewImage({
					current: e,
					urls: imgList,
				});
			},
			//处理图片
			getpictureList(pictureinfo) {
				if (pictureinfo) {
					var splitAdd = pictureinfo.split(",");
					var imgList = []
					for (let i = 0; i < splitAdd.length; i++) {
						let iOrV = splitAdd[i].split("?")[0].split(".")
						let iOrVL = splitAdd[i].split("?")[0].split(".").length - 1
						if (iOrV[iOrVL] != 'mp4') {
							imgList.push(splitAdd[i])
						}
					}
					return imgList
				} else {
					return []
				}
			},
			delectImg(index) {
				uni.showModal({
					title: '提示',
					content: '是否要删除该图片',
					success: res => {
						if (res.confirm) {
							this.imgList.splice(index, 1);
							let idArr = this.dataForm.symbolIds.split(',')
							idArr.splice(index, 1)
							this.dataForm.symbolIds = idArr.join(',')
							let nameArr = this.dataForm.symbolPictures.split(',')
							nameArr.splice(index, 1)
							this.dataForm.symbolPictures = nameArr.join(',')
						}
					}
				});
			},

		},
	}
</script>

<style scoped lang="scss">
	.bigBox {

		.title {
			padding: 8rpx 32rpx;
		}

		.bx-upload {
			padding: 20rpx 30rpx;
			background: #fff;
			border-bottom: 1px solid #d6d7d9;
		}

		.bottom-subside {
			width: 100%;
			height: 120rpx;
		}

		.bx-bottom {
			width: 100%;
			background: #fff;
			display: flex;
			justify-content: space-between;
			align-items: center;
			padding: 20rpx 32rpx;
			position: fixed;
			z-index: 9;
			bottom: 0;
			box-sizing: border-box;

			.btn-left {
				width: 49%;
				height: 92rpx;
				border-radius: 12rpx;
				background: #ffffff;
				display: flex;
				justify-content: center;
				align-items: center;
				color: #0F53AC;
				border: 1px solid #0F53AC;
				font-size: 34rpx;
				font-weight: 500;
				letter-spacing: 0px;
				line-height: 0px;
			}

			.btn-right {
				width: 49%;
				height: 92rpx;
				border-radius: 12rpx;
				background: #0F53AC;
				display: flex;
				justify-content: center;
				align-items: center;
				color: #fff;
				font-size: 34rpx;
				font-weight: 500;
				letter-spacing: 0px;
				line-height: 0px;
			}
		}

		.imgBox {
			display: flex;
			flex-wrap: wrap;

			.img {
				width: 26vw;
				height: 26vw;
				margin-bottom: 4vw;
				margin-right: 4vw;
				position: relative;

				.delect-icon {
					height: 40rpx;
					width: 40rpx;
					position: absolute;
					right: 0rpx;
					top: 0rpx;
					z-index: 0;
				}

				image {
					width: 100%;
					height: 100%;
				}
			}

			.img-add {
				width: 26vw;
				height: 26vw;
				margin-bottom: 4vw;
				margin-right: 4vw;
				display: flex;
				justify-content: center;
				align-items: center;
				flex-direction: column;
				background-color: #F2F2F2;
				border-radius: 4px;

				.image {
					width: 34px;
					height: 34px;
				}
			}

			.video {
				width: 27vw;
				height: 27vw;
				margin-bottom: 4vw;
				margin-right: 4vw;
			}
		}

		.kiss-popup {
			.main {
				min-height: 150px;
				padding: 48rpx 32rpx;
				display: flex;
				flex-wrap: wrap;

				.main-item {
					font-size: 28rpx;
					display: flex;
					align-items: center;
					justify-content: center;
					width: 22%;
					height: 60rpx;
					margin-right: 16rpx;
					margin-bottom: 16rpx;
					border: 1px solid #A6A6A6;
					border-radius: 8rpx;
					position: relative;
					color: #666666;

					.item-check {
						position: absolute;
						right: 0;
						bottom: 0;
						width: 12px;
						height: 12px;
						background-color: #0F53AC;
						color: #fff;
						display: flex;
						justify-content: center;
						align-items: center;
						font-size: 10px;
						border-radius: 6px 0 0 0;

						image {
							width: 16rpx;
							height: 12rpx;
						}
					}
				}

				.main-item-active {
					background-color: rgba(15, 83, 172, 0.1);
					color: #0F53AC;
					border: 1px solid #0F53AC;
				}

				.main-item:nth-child(4n) {
					margin-right: 0;
				}
			}
		}

		.sex-select {
			.sex-item {
				word-break: break-all;
				word-wrap: break-word;
				display: flex;
				justify-content: center;
				align-items: center;
				padding: 20rpx;
				border: 1px solid #f2f2f2;
				margin: 32rpx;
				border-radius: 8rpx;
				position: relative;

				.item-check {
					position: absolute;
					right: 0;
					bottom: 0;
					width: 12px;
					height: 12px;
					background-color: #0F53AC;
					color: #fff;
					display: flex;
					justify-content: center;
					align-items: center;
					font-size: 10px;
					border-radius: 6px 0 0 0;

					image {
						width: 16rpx;
						height: 12rpx;
					}
				}
			}

			.sex-item-active {
				background-color: rgba(15, 83, 172, 0.1);
				color: #0F53AC;
				border: 1px solid #0F53AC;
			}
		}

		.sel {
			color: #A6A6A6;
		}


	}
</style>
